package com.heima.controller;


import com.heima.pojo.dto.VmTypeDto;
import com.heima.pojo.dto.VmTypeSearchDto;
import com.heima.pojo.vo.VmTypeSearchVo;
import com.heima.service.VmTypeService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 * 售货机类型表 前端控制器
 * </p>
 *
 * @author ljk
 * @since 2024-10-20
 */
@RestController
@RequestMapping("/api/vm-service/vmType")
@Api(tags = "设备类型相关接口")
@Slf4j
@RequiredArgsConstructor
public class VmTypeController {
    private final VmTypeService vmTypeService;

    @GetMapping("/search")
    @ApiOperation("设备类型搜索列表")
    public VmTypeSearchVo pageQuery(VmTypeSearchDto vmTypeSearchDto){
        return vmTypeService.pageQuery(vmTypeSearchDto);
    }

    @PostMapping
    @ApiOperation("新增设备类型")
    public Boolean insertVmType(@RequestBody VmTypeDto vmTypeDto){
        vmTypeService.insertVmType(vmTypeDto);
        return true;
    }

    @PutMapping("/{typeId}")
    @ApiOperation("修改设备类型")
    public Boolean updateVmType(@PathVariable Integer typeId,@RequestBody VmTypeDto vmTypeDto){
        vmTypeService.updateVmType(typeId,vmTypeDto);
        return true;
    }

    @DeleteMapping("/{typeId}")
    @ApiOperation("删除设备类型")
    public Boolean delVmType(@PathVariable Integer typeId){
        vmTypeService.delVmType(typeId);
        return true;
    }
}
